﻿## On Action, Launched by code

#ROOT = country
on_monthly_pulse_country = {
	effect = {
		### Natual Decay/Add of Warheads
		if = {
			limit = {
				has_journal_entry = je_Mod_Nuclear_Atomic_Weapon_Tracker
				## always = yes
			}
			change_variable = {
				name = warhead_current_stockpile
				add = warhead_monthly_net_change
			}
			add_modifier = { # Remember it can be in scope, if not, it is in the ROOT scope by default.
				name = Mod_Nuclear_Warheads_Prestige_modifier 
				multiplier = var:warhead_current_stockpile
				is_decaying = no 
				months = 1
			}
		}

		### Natual Decay/Add of Strike Capacity
		if = {
			limit = {
				has_journal_entry = je_Mod_Nuclear_Delivery_Capacity_Tracker
				## always = yes
			}
			change_variable = {
				name = strike_capacity_current_stockpile
				add = strike_capacity_monthly_net_change
			}

			add_modifier = { # Remember it can be in scope, if not, it is in the ROOT scope by default.
				name = Mod_Nuclear_Delivery_Capacity_Prestige_modifier
				multiplier = var:strike_capacity_current_stockpile
				is_decaying = no # Optional, if yes, it will decay, default is no
				months = 1
			}
		}

		### Strike own unincorporated state
		if = {
			limit = {
				any_scope_state = {
					has_decree = decree_strike_own_uninc_state 
				}
			}
			every_scope_state = {
				limit = {has_decree = decree_strike_own_uninc_state}
				trigger_event = mod_nuclear_nuke_own_colony.1
			}
		}
	}
}


# Root = Country
# scope:target = Uprising country
on_revolution_start = {
	## Immediately get nuclear weapon
	effect = {
		if = {
			limit = {
				ROOT = {
					has_journal_entry = je_Mod_Nuclear_Atomic_Weapon_Tracker
				}
			}
			ROOT = {
				change_variable = {
					name = warhead_current_stockpile
					multiply = 0.5
				}
				change_variable = {
					name = strike_capacity_current_stockpile
					multiply = 0.5
				}
			}
			scope:target = {
				add_journal_entry = {
					type = je_Mod_Nuclear_Atomic_Weapon_Tracker
				}
				add_journal_entry = {
					type = je_Mod_Nuclear_Delivery_Capacity_Tracker
				}
				set_variable = {
					name = strike_capacity_current_stockpile
					value = ROOT.var:strike_capacity_current_stockpile
				}
				set_variable = {
					name = warhead_current_stockpile
					value = ROOT.var:warhead_current_stockpile
				}
			}
		}
	}
}